<template>
    <div>
<h3>用户登录</h3>
<table class="table table-bordered">
    <tbody>
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" v-model="queryInfo.UserName"/>
            </td>
        </tr>
        
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="queryInfo.Password"/>
            </td>
        </tr>
        
        <tr>
            <td>
                <input type="button" class="btn btn-primary" value="登录" @click="Logging"/>
            </td>
            <td></td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref,reactive,onMounted } from 'vue';
import { useRouter,useRoute } from 'vue-router';
import axios from 'axios';
import moment from 'moment';
import router from '@/router';
const Router=useRouter();
const Route=useRoute();
let queryInfo=reactive({
    UserName:'',
    Password:''
})
const Logging=()=>{
axios({
    url:'/api/User/UserLog',
    method:'get',
    params:queryInfo
})
.then((res)=>{
    console.log(res.data);
    if(res.data==-2){
        alert("未找到该用户！")
    }
    if(res.data==-1){
        alert("密码错误！")
    }
    if(res.data==1){
        alert("登录成功！")
        if(queryInfo.UserName=="admin"){
            Router.push('/gOGOGO');
        }
        else{
            Router.push('/typeAdd');
        }
    }
})
}
</script>

<style scoped>

</style>